package top.leetcode;

/**
 * @Desc
 * @Author houruiyang
 * @Date 2022/12/21
 **/
public class _009 {

    public static void main(String[] args) {
        boolean palindrome = isPalindrome(121);
        System.out.println(palindrome);
    }

    public static boolean isPalindrome(int x) {
        int a = x;
        if (x == 0) {
            return true;
        }
        if (x < 0 || x % 10 == 0) {
            return false;
        }

        int temp = 0;
        while (x !=0) {
            if (temp < Integer.MIN_VALUE / 10 || temp > Integer.MAX_VALUE / 10) {
                return false;
            }
            int dist = x % 10;
            x = x /10;
            temp = temp * 10 + dist;
        }

        return temp == a;

    }
}
